<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.

$backend = dirname(dirname(__FILE__));
$frontend = dirname($backend);
Yii::setPathOfAlias('backend', $backend);

return array(
    'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',
    'name' => 'DoIt CMS',
    'language' => 'zh_cn',

    'modules' => array(
        'backend' => array(
            'layout' => 'main',
        ),
        'srbac' => array(
            'userclass' => 'User',
            'userid' => 'id',
            'username' => 'username',
            'debug' => false,
            'pageSize' => 20,
            'superUser' => 'admin',
            'css' => 'srbac.css',
            'layout' => 'backend.views.layouts.srbac',
            'notAuthorizedView' => 'backend.views.default.unAuthorized',
            'alwaysAllowed' => array(
                'backend_DefaultError',
                'backend_PasswordLogin',
                'backend_PasswordLogout',
            ),
//            'userActions' => array('Show', 'View', 'List'),
            'listboxNumberOfLines' => 15,
//            'imagesPath' => 15,
            'imagesPack' => 'tango',
            'iconText' => true,
        ),
    ),

    // preloading 'log' component
    'preload' => array('log'),

    // autoloading model and component classes
    'import' => array(
        'application.models.*',
        'application.components.*',
        'application.components.helper.*',
        'application.extensions.YHelper.YArrayExt',
        'application.extensions.YHelper.YUtil',
        'application.extensions.YHelper.YHtml',
        'application.extensions.CModifier.*',
//        'application.extensions.GraphTree.*',
        'application.modules.srbac.controllers.SBaseController',
        'application.extensions.yiidebugtb.*',
    ),

    /**
     * application-level parameters that can be accessed
     * using Yii::app()->params['paramName']
     */
    'params' => require(dirname(__FILE__) . '/config.php'),
//    'frontsetting' => require(dirname(__FILE__) . '/frontsetting.php'),
//    'backend' => require(dirname(__FILE__) . '/backend.php'),

    // application components
    'preload' => array('log'),
    'components' => array(
        'file' => array(
            'class' => 'application.extensions.file.CFile'
        ),
        'cache'=>array(
            'class' => 'system.caching.CFileCache',
//            'directoryLevel' => '2',
        ),
        'request' => array(
            'enableCookieValidation' => true,
        ),
        'errorHandler' => array(
            // use 'site/error' action to display errors
            'errorAction' => 'site/error',
        ),
        'log'=>array(
            'class' => 'CLogRouter',
            'routes' => array(
                array(
                    'class' => 'CFileLogRoute',
                    'levels' => 'error, warning, trace',
//                    'web' => array(
//                        'class' => 'CWebLogRoute',
//                        'levels' => 'trace',
//                    ),
                ),
//                array( // configuration for the toolbar
//                    'class' => 'XWebDebugRouter',
//                    'config' => 'alignLeft, opaque, runInDebug, fixedPos, collapsed, yamlStyle',
//                    'levels' => 'error, warning, trace, profile, info',
//                ),
            ),
        ),
        'authManager' => array(
            'class' => 'CDbAuthManager',
            'connectionID' => 'db',
            'itemTable' => 'items',
            'assignmentTable' => 'assignments',
            'itemChildTable' => 'itemchildren'
        ),
//        'assetManager' => array(
////            'basePath' => dirname(__FILE__) . '/../../public/resource/assets',
////            'baseUrl' => $params['baseUrl'] . 'resource/assets',
//        ),

        'user' => array(
        // enable cookie-based authentication
            'loginUrl' => array('backend/password/login'),
//            'loginUrl' => array('backend', 'password/login'),
            'allowAutoLogin' => true,
        ),

        'db' => array(
            // SQLite 数据库连接
            'connectionString' => 'sqlite:' . dirname(__FILE__) . '/../data/doit.db',
            'tablePrefix' => 'www_',
            'charset' => 'utf8',
            /*
            // MySQL 数据库连接
            'connectionString' => 'mysql:host=localhost;dbname=doit',
            'emulatePrepare' => true,
            'username' => 'root',
            'password' => '',
            'charset' => 'utf8',
            'tablePrefix' => 'www_',
             */
        ),

    ),
);
